/* This do-file replicates table 3 of the paper */ 

cd "" /*input directory here with cleaned data appended_census_mothers using census preparation do-file*/

set more off 

use appended_census_mothers.dta, clear 

********************************************************************************
* Adjust Cohorts to match GHS, see text for detailed explanation * 

gen child_cohort_ghs=child_cohort
replace child_cohort_ghs=child_cohort+1 if yc_birth_month>=7

drop child_cohort 
rename child_cohort_ghs child_cohort 

********************************************************************************
********************************************************************************

*****************
* Sample Select *  
*****************
drop if race==3 | race==4 /* Exclude whites and Indian/Asian, who do not receive the CSG, see text */

* Select Windows * 

keep if child_cohort>=1987 & child_cohort<=1998

** Exclude missing values ** 

drop if emp==1 & (occupation==. | industry==.) &  (year==2001 | year==2007 | year==2011)
drop if emp==. | activity==.

replace yc_birth_month=99 if yc_birth_month==. /*Indicator variable if month of birth missing */

*********************************************************************************
*****************
* Functional Form *  
*****************

local f_form x  /* specify functional formal, x for linear, x x2 for quadratic */ 

gen x=child_cohort-1993
gen CSG=(x>=0)

* Cluster option ** 

gen cluster=household_id 

** Controls ** 

local controls i.race  age c.age#c.age yrs_schooling household_size i.province i.yc_birth_month



*******************
* Define Outcomes *  
*******************
/* These classifications cannot be replicated for 2007, see text for explanation */ 

** 2001 ** 

gen agr_workers=((industry==1 )  | (occ_specific==921 & industry==10)) if year==2001
gen self_noag=(self==1 & agr_workers==0 & emp==1) if year==2001
gen wage_noag=(self==0 & agr_workers==0  & emp==1) if year==2001

** 2007 ** 

replace self_noag=(self==1  & emp==1) if year==2007
replace wage_noag=(self==0  & emp==1) if year==2007


** 2011 ** 

replace agr_workers=((industry==1) | (occ_specific==921 & industry==10))  if year==2011
gen domestic_workers=(occ_most_specific==9131 & agr_workers==0) if year==2011
replace self_noag=(self==1 & agr_workers==0 & domestic_workers==0 & emp==1)  if year==2011
replace wage_noag=(self==0 & agr_workers==0 & domestic_workers==0 & emp==1) if year==2011


*******************
* Regressions     *  
*******************


* Before * 


quietly: reg agr_workers `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2001 & married==1, cluster(cluster) 
outreg2 using rdd_lt_01.tex, tex replace label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)

quietly: reg self_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2001 & married==1, cluster(cluster)
outreg2 using rdd_lt_01.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg wage_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2001 & married==1, cluster(cluster)
outreg2 using rdd_lt_01.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)

quietly: reg agr_workers `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2001 & married==0, cluster(cluster) 
outreg2 using rdd_lt_01.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)

quietly: reg self_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2001 & married==0, cluster(cluster) 
outreg2 using rdd_lt_01.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg wage_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2001 & married==0, cluster(cluster) 
outreg2 using rdd_lt_01.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)

* During * 


quietly: reg self_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2007 & married==1, cluster(cluster)
outreg2 using rdd_lt_07.tex, tex replace label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg wage_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2007 & married==1, cluster(cluster)
outreg2 using rdd_lt_07.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)


quietly: reg self_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2007 & married==0, cluster(cluster) 
outreg2 using rdd_lt_07.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg wage_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2007 & married==0, cluster(cluster) 
outreg2 using rdd_lt_07.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)


* After * 

quietly: reg agr_workers `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==1, cluster(cluster)
outreg2 using rdd_lt_11.tex, tex replace label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg domestic_workers `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==1, cluster(cluster) 
outreg2 using rdd_lt_11.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg self_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==1, cluster(cluster)
outreg2 using rdd_lt_11.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg wage_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==1, cluster(cluster)
outreg2 using rdd_lt_11.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)

quietly: reg agr_workers `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==0, cluster(cluster)
outreg2 using rdd_lt_11.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg domestic_workers `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==0, cluster(cluster) 
outreg2 using rdd_lt_11.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg self_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==0, cluster(cluster)
outreg2 using rdd_lt_11.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)
quietly: reg wage_noag `f_form'  c.(`f_form' )#CSG CSG `controls' [w=weight] if year==2011 & married==0, cluster(cluster)
outreg2 using rdd_lt_11.tex, tex label alpha( 0.01, 0.05, 0.1) dec(4) keep(CSG)

********************************************************************************

cap erase rdd_lt_01.tex
cap erase rdd_lt_01.txt

cap erase rdd_lt_11.tex
cap erase rdd_lt_11.txt
